<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Performance API Example</title>
    <style>
        #myList {
            margin: 20px;
            padding: 0;
            list-style-type: none;
        }
    </style>
</head>
<body>
    <ul id="myList">
        <li>Item 1</li>
        <li>Item 2</li>
        <li>Item 3</li>
    </ul>
    <script>
        document.addEventListener('DOMContentLoaded', function () {
            // performance api
            performance.mark('start');
            // 获取第一个元素
            const firstLi = document.querySelector('#myList li');
            if (firstLi) {
                performance.mark('firstLiRendered');
            }
            performance.mark('end');
            performance.measure('First LI Render Time','start','firstLiRendered')
            const measures = performance.getEntriesByName('First LI Render Time');
            console.log(measures);
            if (measures.length > 0) {
                console.log('First LI Render Time:', measures[0].duration,'ms');
            }
            performance.clearMarks();
            performance.clearMeasures();
        });
    </script>
</body>
</html>